package com.ruoyi.school.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.enums.FileTypeEnum;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.NormalUtils;
import com.ruoyi.common.utils.file.FileTypeUtils;
import com.ruoyi.school.convert.PacAuditRecordsConverter;
import com.ruoyi.school.domain.*;
import com.ruoyi.school.domain.dto.PacAuditApplyDTO;
import com.ruoyi.school.domain.dto.PacAuditRecordsListDTO;
import com.ruoyi.school.domain.vo.PacAuditRecordsVo;
import com.ruoyi.school.domain.vo.PacClassInfoVo;
import com.ruoyi.school.domain.vo.StatisticsVo;
import com.ruoyi.school.enums.AuditStatusEnum;
import com.ruoyi.school.enums.AuditTypeEnum;
import com.ruoyi.school.enums.RoleTypeEnum;
import com.ruoyi.school.handler.wall.AuditDetails;
import com.ruoyi.school.handler.wall.WallStrategy;
import com.ruoyi.school.handler.wall.WallStrategyFactory;
import com.ruoyi.school.service.*;
import com.ruoyi.school.mapper.PacAuditRecordsMapper;
import com.ruoyi.school.utils.CommonUtils;
import com.ruoyi.system.domain.TableData;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import static com.ruoyi.common.utils.PageUtils.startPage;
import static com.ruoyi.common.utils.SecurityUtils.getLoginUser;

/**
 * @author jeremylin
 * @description 针对表【pac_audit_records(审批记录)】的数据库操作Service实现
 * @createDate 2025-05-25 15:33:27
 */
@Service
public class PacAuditRecordsServiceImpl extends ServiceImpl<PacAuditRecordsMapper, PacAuditRecords>
        implements PacAuditRecordsService {

    @Resource
    private StudentService studentService;

    @Resource
    private PacClassService pacClassService;

    @Resource
    private AcademicOutputService academicOutputService;

    @Resource
    private PacActualOutputService pacActualOutputService;

    @Resource
    private PacProSkillCertService pacProSkillCertService;

    @Resource
    private WallStrategyFactory wallStrategyFactory;

    @Resource
    private PacClassTeacherService pacClassTeacherService;

    @Resource
    private PacScientificProjectsService pacScientificProjectsService;

    @Resource
    private PacJournalsOutputService pacJournalsOutputService;

    @Resource
    private PacSoftPatentService pacSoftPatentService;

    @Resource
    private RedisCache redisCache;

    static final String PAC_AUDIT_RECORDS_KEY = "PAC_AUDIT_RECORDS_KEY";

    /**
     * 新增申请记录
     *
     * @param pacAuditRecords
     * @return
     */
    @Override
    public boolean add(PacAuditRecords pacAuditRecords) {
        // 生成审批编号
        String code = NormalUtils.generateNumber();
        pacAuditRecords.setAuditCode(code);
        if (save(pacAuditRecords)) {
            return true;
        }
        return false;
    }

    /**
     * 分页查询
     * 1、根据当前登陆人的角色信息，查询列表
     * 老师查询，自己绑定班级的审批列表
     * 学生查询，自己的审批列表
     *
     * @param listDTO
     * @return
     */
    @Override
    public TableData<PacAuditRecordsVo> getList(PacAuditRecordsListDTO listDTO) {
        LoginUser loginUser = getLoginUser();
        SysUser user = loginUser.getUser();
        List<SysRole> roles = user.getRoles();
        List<String> roleNames = roles.stream().map(SysRole::getRoleKey).collect(Collectors.toList());

        if (roles.isEmpty()) {
            TableData<PacAuditRecordsVo> tableData = TableData.<PacAuditRecordsVo>builder()
                    .build();
            return tableData;
        }

        Student student = initStudentEntity(listDTO);
        // 筛选条件
        // 班级名称列表
        List<String> classNames = new ArrayList<>();
        // 自己的学生信息
        Student myStudentInfo = new Student();
        // 老师查询
        if (roleNames.contains(RoleTypeEnum.TEACHER.getName()) || roleNames.contains(RoleTypeEnum.TEACHER2.getName())) {
            // 获取老师绑定的班级信息
            List<PacClassInfoVo> pacClassInfoVos = pacClassTeacherService.selectByTeacher(user);
            classNames = pacClassInfoVos.stream().map(PacClass::getClassName).collect(Collectors.toList());
        } else if (roleNames.contains(RoleTypeEnum.STUDENT.getName())) {
            // 查询学生信息
            myStudentInfo = studentService.selectByUserId(user.getUserId());
        }

        // 查找学生信息
        List<Student> students = studentService.selectInfo(student);
        List<Integer> ids = students.stream().map(Student::getId).collect(Collectors.toList());

        startPage();
        List<PacAuditRecords> records = lambdaQuery()
                .in(!ids.isEmpty(), PacAuditRecords::getAuditStuId, ids)
                .in(!classNames.isEmpty(), PacAuditRecords::getAuditStuClass, classNames)
                .eq(Objects.nonNull(myStudentInfo.getId()), PacAuditRecords::getAuditStuId, myStudentInfo.getId())
                .eq(Objects.nonNull(listDTO.getAuditStatus()), PacAuditRecords::getAuditStatus, listDTO.getAuditStatus())
                .eq(Objects.nonNull(listDTO.getAuditType()), PacAuditRecords::getAuditType, listDTO.getAuditType())
                .orderByAsc(PacAuditRecords::getAuditStatus)
                .list();

        PageInfo pageInfo = new PageInfo(records);

        // 查询相关学生信息
        List<Long> recordStuIds = records.stream().map(item -> item.getAuditStuId().longValue()).collect(Collectors.toList());
        List<Student> recordStuInfos = studentService.selectByStuIds(recordStuIds);
        List<PacAuditRecordsVo> auditRecordsVoList = PacAuditRecordsConverter.INSTANCE.convertListEntityToListVo(records);
        auditRecordsVoList.forEach(item -> {
            Student recordStuInfo = recordStuInfos.stream().filter(recordStu ->
                    recordStu.getId().equals(item.getAuditStuId().intValue())).findFirst().orElse(null);
            if (recordStuInfo != null) {
                initStudentInfo(item, recordStuInfo);
            }
        });

        TableData<PacAuditRecordsVo> tableData = TableData.<PacAuditRecordsVo>builder()
                .data(auditRecordsVoList)
                .total(pageInfo.getTotal())
                .build();

        return tableData;
    }

    /**
     * 查看审批详情
     *
     * @param pacAuditRecords
     * @return
     */
    @Override
    public PacAuditRecords details(PacAuditRecords pacAuditRecords) {
        LoginUser loginUser = getLoginUser();
        SysUser user = loginUser.getUser();
        List<SysRole> roles = user.getRoles();
        if (roles.get(0).equals(RoleTypeEnum.STUDENT.getName())) {
            throw new RuntimeException("学生无权审批操作");
        }
        if (Objects.isNull(pacAuditRecords.getId())) {
            throw new RuntimeException("传入审批id");
        }
        PacAuditRecords records = getById(pacAuditRecords.getId());
        if (records != null) {
            return records;
        }
        return null;
    }

    /**
     * 审核
     *
     * @param pacAuditRecords
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void audit(PacAuditRecords pacAuditRecords) {
        if (Objects.isNull(pacAuditRecords.getId())) {
            throw new RuntimeException("传入审批id");
        }
        if (Objects.isNull(pacAuditRecords.getAuditStatus())) {
            throw new RuntimeException("传入审批状态");
        }
        // 审核人信息
        pacAuditRecords.setAuditUser(getLoginUser().getUser().getNickName());
        updateById(pacAuditRecords);
        PacAuditRecords details = details(pacAuditRecords);

        WallStrategy strategy = wallStrategyFactory.getStrategy(details.getAuditType());

        if (strategy != null) {
            AuditDetails auditDetails = AuditDetails.builder()
                    .auditType(details.getAuditType())
                    .acAudit(details.getAuditStatus())
                    .auditRecordId(details.getAuditRecordId())
                    .build();

            // 修改原来记录的审批状态
            strategy.audit(auditDetails);
        }

        if(details.getAuditType().equals(AuditTypeEnum.PAC_WALL_TYPE_PARTY.getCode())){
            if(details.getAuditStatus().equals(AuditStatusEnum.AUDITED.getCode())){
                // 修改学生信息
                Student pacStudent = new Student();
                pacStudent.setId(details.getAuditStuId().intValue());
                pacStudent.setPartyMember(2);
                pacStudent.setPoliticalOutlook("党员");

                studentService.updateById(pacStudent);
            }
        }
    }

    /**
     * 学生发起申请
     *
     * @param pacAuditApplyDTO
     */
    @Override
    public void apply(PacAuditApplyDTO pacAuditApplyDTO) {
        Integer auditType = pacAuditApplyDTO.getAuditType();

        if (Objects.isNull(auditType)) {
            throw new RuntimeException("传入申请类型");
        }
        Student student = CommonUtils.getStudent();
        if (Objects.isNull(student)) {
            throw new RuntimeException("请先绑定学生信息");
        }

        if (Objects.equals(auditType, AuditTypeEnum.PAC_WALL_TYPE_ACADEMIC.getCode())) {
            PacAcademicOutput pacAcademicOutput = new PacAcademicOutput();
            pacAcademicOutput.setAcTitle(pacAuditApplyDTO.getAuditCont());
            pacAcademicOutput.setStuName(student.getStuName());
            pacAcademicOutput.setStuNum(student.getStuNum());
            pacAcademicOutput.setStuId(student.getId().longValue());
            pacAcademicOutput.setAcFile(pacAuditApplyDTO.getAuditFile());
            pacAcademicOutput.setResultTypeId(pacAuditApplyDTO.getResultTypeId());

            academicOutputService.add(pacAcademicOutput);
        }
    }

    /**
     * 学术删除审批记录
     * 1、校验是否是自己的审批记录
     * 2、删除审批记录，以及对应类型的审批记录
     *
     * @param pacAuditRecords
     */
    @Override
    public void delete(PacAuditRecords pacAuditRecords) {
        if (Objects.isNull(pacAuditRecords.getId())) {
            throw new ServiceException("传入审批id");
        }

        PacAuditRecords byId = getById(pacAuditRecords.getId());
        Student student = CommonUtils.getStudent();
        if (!Objects.equals(byId.getAuditStuId(), student.getId().longValue())) {
            throw new ServiceException("无权删除该记录");
        }
        if (byId.getAuditType().equals(AuditTypeEnum.PAC_WALL_TYPE_ACADEMIC.getCode())) {
            PacAcademicOutput pacAcademicOutput = new PacAcademicOutput();
            pacAcademicOutput.setId(byId.getAuditRecordId());
            pacAcademicOutput.setAcAuditRecordsId(pacAuditRecords.getId());
            academicOutputService.delete(pacAcademicOutput);
        }
    }

    /**
     * 导出学生的申请记录
     *
     * @param pacAuditRecords
     * @return
     */
    @Override
    public List<PacAuditRecords> myExport(PacAuditRecords pacAuditRecords) {
        Student student = CommonUtils.getStudent();
        pacAuditRecords.setAuditStuId(student.getId().longValue());
        List<PacAuditRecords> records = list(
                new LambdaQueryWrapper<PacAuditRecords>()
                        .eq(PacAuditRecords::getAuditStuId, pacAuditRecords.getAuditStuId())
        );
        return records;
    }

    /**
     * 根据ids找到申请记录
     *
     * @param outputIds
     * @return
     */
    @Override
    public List<PacAuditRecords> getByRecordsIds(List<Long> outputIds) {
        if (CollectionUtils.isEmpty(outputIds)) {
            return Collections.emptyList();
        }
        List<PacAuditRecords> records = list(
                new LambdaQueryWrapper<PacAuditRecords>()
                        .in(PacAuditRecords::getAuditRecordId, outputIds)
        );
        return records;
    }

    /**
     * 根据id，找到对应的审批记录并删除
     *
     * @param id
     */
    @Override
    public void deleteByOutPutId(Long id, Integer type) {
        PacAuditRecords one = lambdaQuery()
                .eq(PacAuditRecords::getAuditRecordId, id)
                .eq(PacAuditRecords::getAuditType, type)
                .one();
        if (Objects.nonNull(one)) {
            removeById(one.getId());
        }
    }

    /**
     * 对应审批记录更新，也要更新审批的记录
     *
     * @param pacAuditRecords
     * @return
     */
    @Override
    public boolean updateByRecord(PacAuditRecords pacAuditRecords) {
        if (Objects.isNull(pacAuditRecords.getAuditRecordId())) {
            throw new BaseException("传入审批记录id");
        }

        if (Objects.isNull(pacAuditRecords.getAuditType())) {
            throw new BaseException("传入审批类别");
        }


        PacAuditRecords one = lambdaQuery()
                .eq(PacAuditRecords::getAuditRecordId, pacAuditRecords.getAuditRecordId())
                .eq(PacAuditRecords::getAuditType, pacAuditRecords.getAuditType()).one();


        if (Objects.nonNull(one)) {
            if (one.getAuditStatus().equals(AuditStatusEnum.AUDITED.getCode())) {
                throw new BaseException("审批记录已审核通过,请勿操作");
            }
            pacAuditRecords.setId(one.getId());
            pacAuditRecords.setAuditStatus(AuditStatusEnum.UNAUDITED.getCode());
            updateById(pacAuditRecords);
        } else {
            throw new BaseException("审批记录异常");
        }

        return false;
    }

    @Override
    public TableData<PacAuditRecordsVo> getListByTeacher(PacAuditRecordsListDTO listDTO) {
        LoginUser loginUser = getLoginUser();
        SysUser user = loginUser.getUser();
        List<SysRole> roles = user.getRoles();
        List<String> roleNames = roles.stream().map(SysRole::getRoleKey).collect(Collectors.toList());

        if (roles.isEmpty()) {
            TableData<PacAuditRecordsVo> tableData = TableData.<PacAuditRecordsVo>builder()
                    .total(0L)
                    .build();
            return tableData;
        }

        Student student = initStudentEntity(listDTO);
        // 筛选条件
        // 班级名称列表
        List<String> classNames = new ArrayList<>();
        // 自己的学生信息
        Student myStudentInfo = new Student();
        // 老师查询
        if (roleNames.contains(RoleTypeEnum.TEACHER.getName()) || roleNames.contains(RoleTypeEnum.TEACHER2.getName())) {
            // 获取老师绑定的班级信息
            List<PacClassInfoVo> pacClassInfoVos = pacClassTeacherService.selectByTeacher(user);
            classNames = pacClassInfoVos.stream().map(PacClass::getClassName).collect(Collectors.toList());
        }

        if(classNames.isEmpty()){
            return TableData.<PacAuditRecordsVo>builder()
                    .total(0L)
                    .build();
        }

        // 查找学生信息
        List<Student> students = studentService.selectInfo(student);
        List<Integer> ids = students.stream().map(Student::getId).collect(Collectors.toList());

        startPage();
        LambdaQueryChainWrapper<PacAuditRecords> wrapper = lambdaQuery()
                .in(!ids.isEmpty(), PacAuditRecords::getAuditStuId, ids)
                .in(!classNames.isEmpty(), PacAuditRecords::getAuditStuClass, classNames)
                .eq(Objects.nonNull(myStudentInfo.getId()), PacAuditRecords::getAuditStuId, myStudentInfo.getId())
                .eq(Objects.nonNull(listDTO.getAuditStatus()), PacAuditRecords::getAuditStatus, listDTO.getAuditStatus())
                .eq(Objects.nonNull(listDTO.getAuditType()), PacAuditRecords::getAuditType, listDTO.getAuditType())
                .ne(PacAuditRecords::getAuditType, AuditTypeEnum.PAC_WALL_TYPE_PARTY.getCode())
                .orderByAsc(PacAuditRecords::getAuditStatus);
        // 只有学业导师 只有实战成果和专业技能证书
        if (roleNames.contains(RoleTypeEnum.TEACHER.getName()) && !roleNames.contains(RoleTypeEnum.TEACHER2.getName())) {
            wrapper.eq(PacAuditRecords::getAuditType, AuditTypeEnum.PAC_WALL_TYPE_PRACTICE.getCode())
                    .or()
                    .eq(PacAuditRecords::getAuditType, AuditTypeEnum.PAC_WALL_SKILL_CERT.getCode());

        }


        if (roleNames.contains(RoleTypeEnum.TEACHER2.getName()) && !roleNames.contains(RoleTypeEnum.TEACHER.getName())) {
            wrapper.eq(PacAuditRecords::getAuditType, AuditTypeEnum.PAC_WALL_TYPE_PRACTICE.getCode())
                    .or()
                    .eq(PacAuditRecords::getAuditType, AuditTypeEnum.PAC_WALL_SKILL_CERT.getCode());
        }
        List<PacAuditRecords> records = wrapper.list();

        PageInfo pageInfo = new PageInfo(records);

        // 查询相关学生信息
        List<Long> recordStuIds = records.stream().map(item -> item.getAuditStuId().longValue()).collect(Collectors.toList());
        List<Student> recordStuInfos = studentService.selectByStuIds(recordStuIds);
        List<PacAuditRecordsVo> auditRecordsVoList = PacAuditRecordsConverter.INSTANCE.convertListEntityToListVo(records);
        auditRecordsVoList.forEach(item -> {
            Student recordStuInfo = recordStuInfos.stream().filter(recordStu ->
                    recordStu.getId().equals(item.getAuditStuId().intValue())).findFirst().orElse(null);
            if (recordStuInfo != null) {
                initStudentInfo(item, recordStuInfo);
            }
        });

        TableData<PacAuditRecordsVo> tableData = TableData.<PacAuditRecordsVo>builder()
                .data(auditRecordsVoList)
                .total(pageInfo.getTotal())
                .build();

        return tableData;
    }

    /**
     * 查询已通过审核的 荣誉
     *
     * @param stuId
     * @return
     */
    @Override
    public List<PacAuditRecords> getPassed(Long stuId) {
        if (stuId == null) throw new BaseException("传入学生id");
        List<PacAuditRecords> list = lambdaQuery()
                .eq(PacAuditRecords::getAuditStuId, stuId)
                .eq(PacAuditRecords::getAuditStatus, AuditStatusEnum.AUDITED.getCode())
                .ne(PacAuditRecords::getAuditType, AuditTypeEnum.PAC_WALL_TYPE_PARTY.getCode())
                .list();
        return list;
    }

    /**
     * 中队长获取审批记录
     *
     * @param listDTO
     * @return
     */
    @Override
    public TableData<PacAuditRecordsVo> listByCaptain(PacAuditRecordsListDTO listDTO) {
        LoginUser loginUser = getLoginUser();
        SysUser user = loginUser.getUser();
        List<SysRole> roles = user.getRoles();

        if (roles.isEmpty()) {
            TableData<PacAuditRecordsVo> tableData = TableData.<PacAuditRecordsVo>builder()
                    .build();
            return tableData;
        }

        Student student = initStudentEntity(listDTO);
        // 筛选条件
        // 查找学生信息
        List<Student> students = studentService.selectInfo(student);
        List<Integer> ids = students.stream().map(Student::getId).collect(Collectors.toList());

        startPage();
        List<PacAuditRecords> records = lambdaQuery()
                .in(!ids.isEmpty(), PacAuditRecords::getAuditStuId, ids)
                .eq(Objects.nonNull(listDTO.getAuditStatus()), PacAuditRecords::getAuditStatus, listDTO.getAuditStatus())
                .eq(Objects.nonNull(listDTO.getAuditType()), PacAuditRecords::getAuditType, listDTO.getAuditType())
                .eq(PacAuditRecords::getAuditType, AuditTypeEnum.PAC_WALL_TYPE_PARTY.getCode())
                .orderByAsc(PacAuditRecords::getAuditStatus)
                .list();

        PageInfo pageInfo = new PageInfo(records);

        // 查询相关学生信息
        List<Long> recordStuIds = records.stream().map(item -> item.getAuditStuId().longValue()).collect(Collectors.toList());
        List<Student> recordStuInfos = studentService.selectByStuIds(recordStuIds);
        List<PacAuditRecordsVo> auditRecordsVoList = PacAuditRecordsConverter.INSTANCE.convertListEntityToListVo(records);
        auditRecordsVoList.forEach(item -> {
            Student recordStuInfo = recordStuInfos.stream().filter(recordStu ->
                    recordStu.getId().equals(item.getAuditStuId().intValue())).findFirst().orElse(null);
            if (recordStuInfo != null) {
                initStudentInfo(item, recordStuInfo);
            }
        });

        TableData<PacAuditRecordsVo> tableData = TableData.<PacAuditRecordsVo>builder()
                .data(auditRecordsVoList)
                .total(pageInfo.getTotal())
                .build();

        return tableData;
    }

    /**
     * 获取最新通过审核的5条数据
     *
     * @return
     */
    @Override
    public List<PacAuditRecords> getTop5() {
        List<PacAuditRecords> list = lambdaQuery()
                .eq(PacAuditRecords::getAuditStatus, 2)
                .orderByDesc(PacAuditRecords::getUpdateTime)
                .last("limit 5")
                .list();
        return list;
    }

    /**
     * 获取统计信息
     *
     * @return
     */
    @Override
    public StatisticsVo getStatistics() {
        StatisticsVo statisticsVo = new StatisticsVo();
        // 学生数量
        long count = studentService.count();
        statisticsVo.setStudentCount(Math.toIntExact(count));

        // 学科竞赛数量 通过审核
        long count1 = academicOutputService.countByAudit();
        statisticsVo.setNum2(Math.toIntExact(count1));

        // 大创项目数量
        long count2 = pacScientificProjectsService.countByAudit();
        statisticsVo.setNum3(Math.toIntExact(count2));

        // 发表论文数量
        long count3 = pacJournalsOutputService.countByAudit();
        statisticsVo.setNum4(Math.toIntExact(count3));

        // 专利、软住数量
        long count4 = pacSoftPatentService.countByAudit();
        statisticsVo.setNum5(Math.toIntExact(count4));

        // 党员数量
        long count5 = studentService.countBypartyMembers();
        statisticsVo.setNum7(Math.toIntExact(count5));

        // 参与实战人次
        long count6 = pacActualOutputService.countByAudit();
        statisticsVo.setNum8(Math.toIntExact(count6));

        // 资格证书
        long count7 = pacProSkillCertService.countByAudit();
        statisticsVo.setNum10(Math.toIntExact(count7));

        return statisticsVo;
    }

    /**
     * 入党申请
     *
     * @param pacAuditRecords
     */
    @Override
    public void applyEntry(PacAuditApplyDTO pacAuditRecords) {
        Student student = CommonUtils.getStudent();
        if(student.getPartyMember().equals(2)){
            throw new BaseException("已是党员，无法申请");
        }

        // 判断改学生是否有未通过 的入党申请
        List<PacAuditRecords> list = lambdaQuery()
                .eq(PacAuditRecords::getAuditStuId, student.getId())
                .eq(PacAuditRecords::getAuditType, AuditTypeEnum.PAC_WALL_TYPE_PARTY.getCode())
                .eq(PacAuditRecords::getAuditStatus, 1)
                .list();

        if(!list.isEmpty()){
            throw new BaseException("您有未通过 的入党申请");
        }
        PacAuditRecords pacAuditRecords1 = new PacAuditRecords();
        pacAuditRecords1.setAuditFile(pacAuditRecords.getAuditFile());
        pacAuditRecords1.setAuditTitle("入党申请");
        pacAuditRecords1.setAuditCont(pacAuditRecords.getAuditCont());

        // 插入学生信息
        pacAuditRecords1.setAuditStu(student.getStuName());
        pacAuditRecords1.setAuditStuId(student.getId().longValue());

        if (Objects.nonNull(pacAuditRecords.getAuditFile())) {
            FileTypeEnum fileTypeName = FileTypeUtils.getFileTypeName(pacAuditRecords.getAuditFile());
            pacAuditRecords1.setAuditFileType(fileTypeName.getCode());
        }

        pacAuditRecords1.setAuditType(AuditTypeEnum.PAC_WALL_TYPE_PARTY.getCode());
        pacAuditRecords1.setAuditStuClass(student.getStuClass());
        pacAuditRecords1.setAuditStuId(student.getId().longValue());

        add(pacAuditRecords1);
    }

    /********************************私有方法********************************/

    private static void initStudentInfo(PacAuditRecordsVo item, Student recordStuInfo) {
        item.setStuName(recordStuInfo.getStuName());
        item.setStuNum(recordStuInfo.getStuNum());
        item.setAuditStuClass(recordStuInfo.getStuClass());
        item.setStuFaculties(recordStuInfo.getStuFaculties());
        item.setYearEnrollment(recordStuInfo.getYearEnrollment());
        item.setStuClass(recordStuInfo.getStuClass());
        item.setStuPhone(recordStuInfo.getStuPhone());
        item.setStuGradYear(recordStuInfo.getStuGradYear());
        item.setStuPlace(recordStuInfo.getStuPlace());
    }


    private static Student initStudentEntity(PacAuditRecordsListDTO listDTO) {
        Student student = new Student();
        student.setStuNum(listDTO.getStuNum());
        student.setStuName(listDTO.getStuName());
        student.setStuClass(listDTO.getStuClass());
        student.setStuFaculties(listDTO.getStuFaculties());
        student.setYearEnrollment(listDTO.getYearEnrollment());

        return student;
    }
}




